package com.zyd.databindingdemo.mvvm.viewmodel;

import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import com.google.android.material.snackbar.BaseTransientBottomBar;
import com.google.android.material.snackbar.Snackbar;
import com.zyd.databindingdemo.MainActivity;
import com.zyd.databindingdemo.databinding.ActivityLogin2MainBinding;
import com.zyd.databindingdemo.mvvm.model.User;
import com.zyd.databindingdemo.util.CustomToast;

public class ViewModel {
    public ActivityLogin2MainBinding binding;
    public User user;

    public ViewModel(ActivityLogin2MainBinding binding, User user) {
        this.binding = binding;
        this.user = user;
    }

    public void Login(View view){
        if (user.getmUserName().equals( "admin" ) && user.getmPassWord().equals( "123456" )){
            Log.d( "TAG","success" );
            CustomToast.getInstance().showToastCustom(binding.login.getContext(),"success",
                    Gravity.CENTER);
        }else {
            Log.d( "TAG","fail" );
            CustomToast.getInstance().showToastCustom(binding.login.getContext(),"fail",
                    Gravity.CENTER);
        }
        Log.d( "TAG",user.getmUserName()+"" );
        Log.d( "TAG",user.getmPassWord()+"" );


    }
}

